// import App from '@/App.tsx';
import { lazy, Suspense } from "react";
import LoadingComponent from "@/components/Loading/index.tsx";
//import Management from '@/pages/Management/index.tsx';
import NoLogin from "@/pages/NoLogin/index.tsx";

// import {HashRouter,Routes,Route,Navigate} from 'react-router-dom';
import { Navigate, Link } from "react-router-dom";

const Management = lazy(() => import("@/pages/Management/index.tsx"));

const Home = lazy(() => import("@/pages/Management/Home/index.tsx"));

const Category = lazy(() => import("@/pages/Management/Category/index.tsx"));

const Goods = lazy(() => import("@/pages/Management/Lib/Goods/index.tsx"));
const InStorage = lazy(
  () => import("@/pages/Management/Lib/InStorage/index.tsx")
);
const InStorageAdd = lazy(
  () => import("@/pages/Management/Lib/InStorage/Add/index.tsx")
);
const OutStorage = lazy(
  () => import("@/pages/Management/Lib/OutStorage/index.tsx")
);
const OutStorageAdd = lazy(
  () => import("@/pages/Management/Lib/OutStorage/Add/index.tsx")
);
const History = lazy(() => import("@/pages/Management/Lib/History/index.tsx"));
const Accounts = lazy(
  () => import("@/pages/Management/Lib/Accounts/index.tsx")
);
const Inventory = lazy(
  () => import("@/pages/Management/Lib/Inventory/index.tsx")
);
const Suppliers = lazy(() => import("@/pages/Management/Suppliers/index.tsx"));
const Depart = lazy(() => import("@/pages/Management/Depart/index.tsx"));
const Export = lazy(() => import("@/pages/Management/Export/index.tsx"));

const About = lazy(() => import("@/pages/Management/About/index.tsx"));

const ChangePassword = lazy(
  () => import("@/pages/Management/User/ChangePassword/index.tsx")
);
const UsersManage = lazy(
  () => import("@/pages/Management/User/Manage/index.tsx")
);

const lazyload = (outlet) => (
  <>
    <Suspense fallback={<LoadingComponent />}>{outlet}</Suspense>
  </>
);

const routes = [
  {
    path: "/",
    element: <Navigate to="/management/home"></Navigate>,
    breadcrumbName: "主页",
  },
  {
    path: "/nologin",
    element: <NoLogin />,
    breadcrumbName: "未登录",
  },
  {
    path: "/management",
    element: lazyload(<Management />),
    breadcrumbName: "管理系统",
    children: [
      {
        path: "home",
        element: lazyload(<Home />),
        breadcrumbName: "主页",
      },
      {
        path: "user/change_password",
        element: lazyload(<ChangePassword />), //<>这是修改密码的页面，功能还在开发中</>,
        breadcrumbName: "修改密码",
      },
      {
        path: "user/manage",
        element: lazyload(<UsersManage />), //<>这是用户管理的页面，功能还在开发中</>,
        breadcrumbName: "用户管理",
      },
      {
        path: "category",
        element: lazyload(<Category />),
        breadcrumbName: "分类管理",
      },
      {
        path: "lib/goods",
        element: lazyload(<Goods />),
        breadcrumbName: "库存管理",
      },
      {
        path: "lib/in_storage",
        element: lazyload(<InStorage />),
        breadcrumbName: "入库单",
      },
      {
        path: "lib/in_storage/add",
        element: lazyload(<InStorageAdd />),
        breadcrumbName: "新增入库单",
      },
      {
        path: "lib/out_storage",
        element: lazyload(<OutStorage />),
        breadcrumbName: "出库单",
      },
      {
        path: "lib/out_storage/add",
        element: lazyload(<OutStorageAdd />),
        breadcrumbName: "新增出库单",
      },
      {
        path: "lib/inventory",
        element: lazyload(<Inventory />),
        breadcrumbName: "盘点",
      },
      {
        path: "lib/history",
        element: lazyload(<History />),
        breadcrumbName: "历史单据",
      },
      {
        path: "lib/accounts",
        element: lazyload(<Accounts />),
        breadcrumbName: "账表汇总",
      },
      {
        path: "suppliers", //供货商
        element: lazyload(<Suppliers />),
        breadcrumbName: "供货商维护",
      },
      {
        path: "depart", //部门
        element: lazyload(<Depart />),
        breadcrumbName: "部门维护",
      },
      {
        path: "export", //导出
        element: lazyload(<Export />),
        breadcrumbName: "数据导出",
      },

      {
        path: "about",
        element: lazyload(<About />),
        breadcrumbName: "关于",
      },
      {
        path: "*",
        element: (
          <div>
            该页无法显示，请<Link to="/management/home">点击此处返回</Link>
          </div>
        ),
      },
    ],
  },
];

// const baseRouter = () => {

//     return <>
//         <HashRouter>
//             <Routes>
//                 <Route path="/" element={<App/>}>
//                     <Route path="/" element={<Navigate to="/management"/>}></Route>
//                     <Route path="/management" element={<Management/>}></Route>
//                     <Route path="/nologin" element={<NoLogin/>}></Route>
//                 </Route>
//             </Routes>
//         </HashRouter>
//     </>
// }

// export default baseRouter;

export default routes;
